use crate::{dto, mq};
use std::sync::Arc;

pub struct ClientManager {
    traffic_steering_rule: Arc<mq::client::node::endpoint::traffic_steering_rule::Client>,
    pub network_acl: Arc<mq::client::node::endpoint::traffic_steering_rule::network_acl::Client>,
    pub te_policy_group: Arc<mq::client::node::endpoint::traffic_steering_rule::te_policy_group::client_manager::ClientManager>,
}

impl ClientManager {
    pub fn new(client: Arc<mq::client::Client>) -> Self {
        Self {
            traffic_steering_rule: Arc::new(
                mq::client::node::endpoint::traffic_steering_rule::Client::new(client.clone()),
            ),
            network_acl: Arc::new(
                mq::client::node::endpoint::traffic_steering_rule::network_acl::Client::new(
                    client.clone(),
                ),
            ),
            te_policy_group: Arc::new(
                mq::client::node::endpoint::traffic_steering_rule::te_policy_group::client_manager::ClientManager::new(
                    client,
                ),
            ),
        }
    }
    pub async fn publish_setup_event(
        &self,
        node_id: &str,
        payload: dto::event::endpoint::traffic_steering_rule::SetupEventPayload,
    ) -> Result<(), anyhow::Error> {
        self.traffic_steering_rule
            .publish_setup_event(node_id, payload)
            .await
    }

    pub async fn publish_delete_event(
        &self,
        node_id: &str,
        payload: dto::event::endpoint::traffic_steering_rule::DeleteEventPayload,
    ) -> Result<(), anyhow::Error> {
        self.traffic_steering_rule
            .publish_delete_event(node_id, payload)
            .await
    }
}
